﻿// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.AI;

IChatClient client = new OllamaChatClient(new Uri("http://localhost:9527/"), "deepseek-r1:1.5b");
Console.WriteLine("Hello, World!");

while (true)
{
    Console.WriteLine("Please enter a message to send to the chat server (or type 'exit' to quit):");
    string? message = Console.ReadLine();

    if (message != null && message.ToLower() == "exit")
    {
        break;
    }

    if (!string.IsNullOrEmpty(message))
    {
        var response = client.CompleteStreamingAsync(message);

        await foreach (var item in response)
        {
            Console.Write(item);
        }
        Console.WriteLine(); // 换行以便下一次输入
    }
    else
    {
        Console.WriteLine("No message entered.");
    }
}

Console.WriteLine("Goodbye!");
